package pack;

public class factor
{
	public static void main(String[] args)
	{
		long start;
		
		start = System.nanoTime();
		System.out.println(factorial(5));
        System.out.println("Time of running: "+(System.nanoTime()-start)+" nanosec");
        
		start = System.nanoTime();
		System.out.println(factorial_rec(10));
        System.out.println("Time of running: "+(System.nanoTime()-start)+" nanosec");
	}
	
    public static int factorial(int n)
    {
        int ret = 1;
        for (int i = 1; i <= n; ++i) ret *= i;
        return ret;
    }
    
    public static int factorial_rec(int n)
    {
        if (n == 0) return 1;
        return n * factorial_rec(n-1);
    }
}
